// components/placeholder/placeholder.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    template: {
      type: Array
    },
    type: {
      type: String
    },
    title: {
      type: String
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    systemInfo: getApp().core.getSystemInfoSync(),
    is_shop_info: false,
    is_search: false,
    shop_info_height: 0,
    search_height: 78,
    default_height: 0,
    bar_color: {
      frontColor: '#000000',
      backgroundColor: '#ffffff',
    }
    
  },

  /**
   * 组件的方法列表
   */
  methods: {
    px2rpx: function (px) {
      const screenWidth = this.data.systemInfo.screenWidth
      return (750 / screenWidth) * px
    }
  },
  lifetimes: {
    attached: function () {
      var is_shop_info = false
      var is_search = false
      var shop_info_height = 0
      var default_height = this.px2rpx(this.data.systemInfo.statusBarHeight) + 88
      var bar_color = getApp().core.getStorageSync(getApp().const.NAVIGATION_BAR_COLOR)
      if (this.data.type == 'diy' && this.data.template.length > 0) {
        if (this.data.template[0].type == 'shop_info') {
          is_shop_info = true
          shop_info_height = this.px2rpx(this.data.systemInfo.statusBarHeight) + 85
        }
        if (this.data.template[1].type == 'search') {
          is_search = true
        }
        
      }
      if(this.data.type == 'diy'){
        bar_color= {
          frontColor: '#fff',
          backgroundColor: '#17BC99',
        }
      }
      this.setData({
        bar_color: bar_color,
        is_shop_info: is_shop_info,
        is_search: is_search,
        shop_info_height: shop_info_height,
        default_height: default_height
      })
    }
  }
})
